from array import array     #1
from random import random

if __name__ == '__main__':
    floats = array('d', (random() for i in range(10**7)))      #2
    print(floats[-1])   #3
    fp = open('floats.bin', 'wb')
    floats.tofile(fp)   #4
    fp.close()
    floats2 = array('d')    #5
    fp = open('floats.bin', 'rb')
    floats2.fromfile(fp, 10**7)     #6
    fp.close()
    print(floats2[-1])  #7
    print(floats2 == floats)    #8